package com.elektronikforumet.camalert;

import java.io.File;

import android.content.Context;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class FileView extends LinearLayout {

	//private Context mCtx = null;
	private File mFile = null;
	private ImageView mImage = null;
	private TextView mText = null;
	private boolean mUp = false;
	
	public FileView(Context ctx, File file, boolean up) {
		super(ctx);
		
		mImage = new ImageView(ctx);
		this.addView(mImage);
		
		mText = new TextView(ctx);
		this.addView(mText);
		
		setFile(file, up);
	}
	
	public void setFile(File file, boolean up) {
		mFile = file;
		mUp = up;
		
		if(up || file.isDirectory()) {
			mImage.setImageResource(R.drawable.folder);
		} else {
			mImage.setImageResource(R.drawable.document);
		}
		
		if(up) {
			mText.setText("..");
		} else {
			mText.setText(file.getName());
		}
	}
	
	public File getFile() {
		return mFile;
	}
	
	public void setUp(boolean up) {
		setFile(mFile, up);
	}
	
	public boolean getUp() {
		return mUp;
	}
}
